import {AXIOS} from '../utils/request'
import store from '../store/index'
import {Message } from 'element-ui'

//后台用户登录
export const userLogin = async (params) => {
	try {
	    let res = await AXIOS.post('/admin/login', params);
	    if (res.code === 200) {
			store.commit('setToken',res.data.access_token,{root:true})
			store.commit('setUsername',res.data.username,{root:true})
		} else {
			Message.error(JSON.stringify(res.message))
		}
	    return [null, res]
	} catch (e) {
	    return [e, null]
	}
}